import { Controller, Get } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { AppService } from './app.service';

@ApiTags('应用')
@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  @ApiOperation({ summary: '获取应用信息' })
  @ApiResponse({
    status: 200,
    description: '应用基本信息',
    schema: {
      type: 'object',
      properties: {
        name: { type: 'string', example: 'FaceTime Backend API' },
        version: { type: 'string', example: '1.0.0' },
        description: { type: 'string', example: '视频通话应用后端服务' },
        environment: { type: 'string', example: 'development' },
        timestamp: { type: 'string', format: 'date-time' },
        uptime: { type: 'string', example: '1h 30m 45s' },
        status: { type: 'string', example: 'running' },
      },
    },
  })
  getAppInfo() {
    return this.appService.getAppInfo();
  }

  @Get('version')
  @ApiOperation({ summary: '获取应用版本' })
  @ApiResponse({
    status: 200,
    description: '应用版本信息',
    schema: {
      type: 'object',
      properties: {
        version: { type: 'string', example: '1.0.0' },
        buildTime: { type: 'string', format: 'date-time' },
        gitCommit: { type: 'string', example: 'abc123def456' },
        nodeVersion: { type: 'string', example: 'v18.17.0' },
      },
    },
  })
  getVersion() {
    return this.appService.getVersion();
  }

  @Get('ping')
  @ApiOperation({ summary: '健康检查' })
  @ApiResponse({
    status: 200,
    description: '服务状态',
    schema: {
      type: 'object',
      properties: {
        message: { type: 'string', example: 'pong' },
        timestamp: { type: 'string', format: 'date-time' },
        uptime: { type: 'number', example: 12345 },
      },
    },
  })
  ping() {
    return this.appService.ping();
  }
}
